package cn.webrx;

import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;

public class TreeMap2 {
    public static void main(String[] args) {
        TreeMap<Integer, String> tm = new TreeMap<>();
        tm.put(1, "hello1");
        tm.put(2, "hello22");
        tm.put(3, "hello333");
        tm.put(10, "hello10");
        tm.put(4, "hello4444");
        System.out.println(tm);
        //.descendingMap() 返回一个Map 根据key降序，对原来的TreeMap没有改变
        Map<Integer,String> t2 = tm.descendingMap();
        System.out.println(tm);
        System.out.println(t2);
        t2.put(20,"java");

        System.out.println(t2);
    }
}
